﻿package kaze 
{
    import vegas.display.ApplicationDisplay;
    import vegas.net.JSONLoader;

    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.net.URLRequest;
    import flash.system.Security;
    import flash.text.TextField;
    import flash.text.TextFormat;

    [SWF(width="980", height="760", frameRate="24", backgroundColor="#CCCCCC")]
    // -default-size 980 760 -default-frame-rate 31 -default-background-color 0xCCCCCC -target-player=10.0 -optimize=true
    
    public class Application extends ApplicationDisplay 
    {
        /**
         * Creates a new Application instance.
         */
        public function Application()
        {
            Security.loadPolicyFile( "http://twitter.com/crossdomain.xml" ) ;
            Security.loadPolicyFile( "http://search.twitter.com/crossdomain.xml" ) ;
            
            stage.align     = StageAlign.TOP_LEFT ;
            stage.scaleMode = StageScaleMode.NO_SCALE ;
            
            var request:URLRequest = new URLRequest("http://www.twitter.com/statuses/user_timeline.json?screen_name=ekameleon&count=1") ;
            
            loader = new JSONLoader() ;
            
            loader.addEventListener( Event.COMPLETE , complete ) ;
            
            field = new TextField() ;
            
            field.autoSize = "left" ;
            field.defaultTextFormat = new TextFormat("arial",10) ;
            
            addChild( field ) ;
            
            loader.load( request ) ;
        }
        
        protected var field:TextField ;
        
        protected var loader:JSONLoader ;
        
        protected function complete( e:Event ):void
        {
            field.text = loader.data[0].text ;
        }
    }
}
